﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RayDen.Library.Data.Utility
{
    public class FileHelper
    {

        public static double[] Read(string fileName, out int th, out int td, out int pd)
        {
            int size = ((int)(new FileInfo(fileName).Length-12));
            Console.WriteLine("Brdf {0} opened. Dataset size {1} bytes)", fileName, size);
            var data = new double[size / sizeof(double)];
            int index = 0;
            using (var fs = new FileStream(fileName, FileMode.Open, FileAccess.Read))
            {
                using (var br = new BinaryReader(fs))
                {
                    th = br.ReadInt32();
                    td = br.ReadInt32();
                    pd = br.ReadInt32();

                    while (index < size/8)
                        data[index++] = br.ReadDouble();
                }
            }
            return data;
        }
    }
}
